namespace AceMobile.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class addTablet : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Tablets",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false),
                        Size = c.Single(nullable: false),
                        Price = c.Int(nullable: false, defaultValue: 0),
                        ConciseFeature = c.String(nullable: false, defaultValue: ""),
                        DetailFeature = c.String(nullable: false),
                        ImageUrl = c.String(nullable: false),
                        ManufacturingDate = c.DateTime(nullable: false),
                        MadeIn = c.String(nullable: false),
                        Amount = c.Int(nullable: false, defaultValue: 0),
                        SumAmount = c.Int(nullable: false, defaultValue: 0),
                        ViewAmount = c.Int(nullable: false, defaultValue: 0),
                        TabletOSID = c.Int(nullable: true),
                        TabletProducerID = c.Int(nullable: true),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.TabletOS", t => t.TabletOSID, cascadeDelete: true)
                .ForeignKey("dbo.TabletProducers", t => t.TabletProducerID, cascadeDelete: true)
                .Index(t => t.TabletOSID)
                .Index(t => t.TabletProducerID);
            
            CreateTable(
                "dbo.TabletOS",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                    })
                .PrimaryKey(t => t.ID);
            
            CreateTable(
                "dbo.TabletProducers",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false),
                    })
                .PrimaryKey(t => t.ID);
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.Tablets", new[] { "TabletProducerID" });
            DropIndex("dbo.Tablets", new[] { "TabletOSID" });
            DropForeignKey("dbo.Tablets", "TabletProducerID", "dbo.TabletProducers");
            DropForeignKey("dbo.Tablets", "TabletOSID", "dbo.TabletOS");
            DropTable("dbo.TabletProducers");
            DropTable("dbo.TabletOS");
            DropTable("dbo.Tablets");
        }
    }
}
